/**
 * 功能描述 导航栏
 */

define(function (require, exports, module) {
	var Subnav = require("subnav");
	var aw = require("ajaxwrapper")
	var store =require("store");
	
    var instance = {
        initComponent:function (params,widget){
        	var subnav=new Subnav({
        		parentNode:".J-subnav",
        		model:{
            		title:"体验订金",
            		items:[{
						id : "search",
						type : "search",
						placeholder:"联系人/联系方式",
						handler : function(str){
							var grid = widget.get("grid");
							var obj = {
									s:str,
									properties : "nonMemberGroup.contactName,nonMemberGroup.contactPhone",
									"orderString":"checkInDate:desc",
									fetchProperties:"*,nonMemberGroup.*,nonMemberGroup.servicePoint.name," +
	            					"nonMemberGroup.servicePoint.pkServicePoint," +
	            					"nonMemberGroup.operator.pkUser," +
	            					"nonMemberGroup.signUps.version," +
	            					"signUpRooms.roomType.*," +
	            					"signUpRooms.count"
							};
							aw.ajax({
								url:"api/nonmemgroupreserve/search",
								data:obj,
								dataType:"json",
								success:function(data){
									grid.setData(data);
								}
							});
						}
					},{
            			 id:"status",
			   			 tip:"收费状态",
			   			 type:'buttongroup',
						 items:[{
								key :"Initial",
								value:"待收费"
						 },{
								key :"Effective",
								value:"已收费"
						 },{
								key:"",
								value:"全部"
						 }],
            			handler:function(key,element){
    						widget.get("grid").refresh();
    					}
            		},{
            			id:"operateDate",
						tip:"登记日期",
						type:"daterange",
						ranges:{
							  "时间":[moment().subtract(1,"month"),  moment()],
						},
						 defaultRange : "时间",
						handler : function(time){
							 widget.get("grid").refresh();
						}
            		},{
            			id:"return",
    					type:"button",
    					text:"返回",
    					show:false,
    					handler:function(){
    						widget.get("optiongrid").setData([]);
    						widget.get("grid").refresh();
    						widget.hide([".J-editgrid",".J-form"]).show([".J-grid"]);
    						widget.get("subnav").hide(["return"]).show(["search","status","operateDate"]);
    					}
            		}]
        		}
        	});
        	widget.set("subnav",subnav);

        }
    };
    module.exports = instance;
});
